<template>
  <div class="mainbox">
    <el-container>
      <el-header>
        <div class="logo">
          <span>数据展示系统</span>
          <div>
            <el-button type="primary" size="default">asdfasdf</el-button>
          </div>

          <el-button type="primary" size="small" @click="onSubmit">
            退出系统
          </el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            :router="true"
          >
            <el-submenu
              :index="'one' + index"
              v-for="(item, index) in menulist.menus"
              :key="item.name"
            >
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.name }}</span>
              </template>
              <el-menu-item
                v-for="child in item.children"
                :key="child.name"
                :index="child.path"
              >
                {{ child.name }}
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menulist: {},
    }
  },
  created() {
    this.getmenulist()
    this.getrouters()
  },
  mounted() {},
  methods: {
    onSubmit() {
      this.$router.push({ path: '/login' })
    },
    async getmenulist() {
      this.menulist = await require('../assets/menus.json')
    },
    async getrouters() {},
  },
}
</script>

<style scoped lang="less">
.mainbox,
.el-container,
.el-header,
.el-aside {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: #2d3d4d;
}
.el-menu {
  border-right: none;
}
.el-aside {
  background-color: #5d6d7d;
}
.el-main {
  background-color: #fff;
}
.logo {
  display: flex;
  height: 100%;
  margin: 0 15px;
  align-items: center;
  justify-content: space-between;
}
.logo span {
  font-size: 18px;
  color: #fff;
}
.logo .el-button {
  background-color: red;
}
</style>
